<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh_cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>JIM管理系统</title>
<%@ include file="../../../inc/main-css.jsp"%>
<%@ include file="../../../inc/main-js.jsp"%>
<script type="text/javascript">
	 $(function() {
        var editor = editormd("editormd", {
         	width   : "100%",
            height  : 640,
            syncScrolling : "single",
        
            path : "../static/lib/editormd/lib/" // Autoload modules mode, codemirror, marked... dependents libs path
            
        });

        
        $("#saveBtn").click(function(){
        
        	if($("#inputTitle").val()==""){
        		alert("标题不能为空！");
        		return;
        	}
        	$.ajax({
        		url:"update",
        		type:"post",
        		dataType:"json",
        		data:{
        			"id":$("#id").val(),
        			"title":$("#inputTitle").val(),
        			"type":$("#selType").val(),
        			"description":$("#inputDescription").val(),
        			"content":$("#editormd textarea").text()
        		},
        		success:function(data){
        			if(data){
        				if(data.success){
        					alert(data.message);
        				}else{
        					alert(data.message);
        				}
        			}
        		}
        	});
        });
        
    });
</script>
</head>
<body>
	<div id="wrapper" class="container-fluid">
		<%@ include file="../../../inc/menu.jsp"%>
		<div id="page-wrapper">
			<div class="container-fluid" style="height: 100%">
				<!-- <button id="editorBtn" class="btn btn-default">click</button> -->
				<form class="form-horizontal">
				<input type="hidden" id="id" value="${article.id }"/>
				  <div class="form-group">
				    <label for="inputTitle" class="col-sm-2 control-label">文章标题</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" id="inputTitle" placeholder=文章标题 value="${article.title }">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="inputDescription" class="col-sm-2 control-label">文章描述</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" id="inputDescription" placeholder="文章描述" value="${article.description }">
				    </div>
				  </div>
				  <div class="form-group">
				    <label for="selType" class="col-sm-2 control-label">文章类型</label>
				    <div class="col-sm-10">
				      <select id="selType" class="form-control">
				      	<c:forEach items="${articleTypeList }" var="at">
				      		<option value="${at.type }"
				      			<c:if test="${article.type == at.type }">selected</c:if>
				      		>${at.type } | ${at.typename }</option>
				      	</c:forEach>
				      	
				      </select>
				    </div>
				  </div>
				  <div class="col-sm-offset-11 col-sm-10">
				  	<button id="saveBtn" type="button" class="btn btn-default">保存</button>
				  </div>
				  
				</form>
				<div id="editormd">
				    <textarea style="display:none;">${article.content }</textarea>
				</div>
				
			</div>
			<!-- /.container-fluid -->
		</div>
	</div>
</body>

</html>